﻿@model protogen.site.Controllers.HomeController.IndexModel
@{
    ViewData["Title"] = "Generator";
}
<h2>@ViewData["Title"].</h2>
<p><a href="/about">Wait... what is this?</a></p>
<p>If this tool has been useful: <a href="https://www.buymeacoffee.com/marcgravell" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" /></a></p>
<section>
    <h3>.proto Schema (can be <a href="https://developers.google.com/protocol-buffers/docs/proto">proto2</a> or <a href="https://developers.google.com/protocol-buffers/docs/proto3">proto3</a>):</h3>
    <p>Pending work items in code generated by protogen (protobuf-net):</p>
    <ul>
        <li>switch to bitwise mask ops for optional field tracking (rather than nullable-per-field)</li>
        <li>intellisense comments</li>
    </ul>
    <div>
        <button id="generatecsharp">Generate</button>
        <select id="tooling">
            <optgroup label="protobuf-net">
                <option value="protogen:C#" selected="selected">(protogen) C#</option>
                <option value="protogen:VB">(protogen) VB</option>
            </optgroup>
            @if (Model.CanUseProtoc)
            {
                <optgroup label="@Model.ProtocVersion">
                    @foreach (var option in protogen.site.Controllers.HomeController.ProtocTooling.Options)
                    {
                        <option value="@option.Tooling">(protoc) @option.Caption</option>
                    }
                    
                </optgroup>
            }
        </select>
        @if (Model.CanUseProtoc)
        {
            <span>(note: only single-file outputs work currently; need tabbed editor)</span>
        }
        else
        {
            <span>(sorry, protoc is not available: @Model.ProtocVersion)</span>
        }
    </div>
    <div id="protocontainer" style="width:100%; max-width:unset;height:600px;border:1px solid grey"></div>
    <script>

    </script>
    <p>Not sure what to use? How about <a href="https://raw.githubusercontent.com/google/protobuf/master/src/google/protobuf/descriptor.proto">descriptor.proto</a>?</p>
    <p>download <code>protogen</code> <a href="/protogen/protogen 1.0.5.zip">1.0.5 (windows)</a> to use this tool at the command-line</p>
    <p>tip: if needed, you can <a href="https://github.com/mgravell/protobuf-net/issues/343#issuecomment-360127902">generate C# 3.0 instead of C# 6.0</a></p>
</section>
<section id="coderesult" style="display: none;">
    <h3>Generated Code</h3>
    <div id="csharpcontainer" style="width:100%; max-width:unset;height:600px;border:1px solid grey"></div>
</section>
<script src="~/lib/monaco-editor/min/vs/loader.js"></script>

@section Scripts
{
<script src="~/js/home.js" asp-append-version="true"></script>
}